package com.flying.inherit.inheritanceTest1;

/**
 * @ClassName: InheritanceTest1
 * @createDate: 2023/6/27 16:33
 * @author: liu
 * @description:继承-子类没有定义父类同名的变量
 */
public class Test1 {
    public static void main(String[] args) {
        Father f=new Father();
        Son s=new Son();

        System.out.println(f.getInfo());  //  atguigu
        System.out.println(s.getInfo());  //  atguigu

        s.setInfo("尚硅谷");

        System.out.println(f.getInfo());   // atguigu
        System.out.println(s.getInfo());   // 尚硅谷

    }
}

 class Father{
    private String info="atguigu";
    public void setInfo(String info){
        this.info=info;
    }
    public String getInfo(){
        return info;
    }
}

class Son extends Father {

}
